
import { information, provinceChange, getService, dupliCation } from "@/utils/method.js"

export default {
  methods: {
    getTravielInfor(num) {
      if (
        this.formationdata.center_id == "" &&
        this.formationdata.travel_agency_intro == "" &&
        this.formationdata.address == "" &&
        this.formationdata.area == "" &&
        this.formationdata.city == "" &&
        this.formationdata.province == "" &&
        this.formationdata.travel_agency_pic == "" &&
        this.formationdata.travel_agency_name == ""
      ) {
        this.$message.error("请完善资料");
      } else {
        // console.log(this.formationdata);
        information(this.formationdata)
          .then(() => {
            // console.log(res);

            this.$message({ message: "基础信息已更改 🙂", type: "success" });
            if (num == 1) {
              this.$emit("activeChange", 3); // 步骤条
            } else return
          })
          .catch((error) => {
            this.$message.error(error);
          });
      }
    },
    // 运营中心前置
    getcode(code) {
      this.formationdata.center_id = 0
      provinceChange(code)
        .then((res) => {
          this.city1 = res.data.data;
        })
        .catch((error) => {
          console.log(error);
          this.$message.error(error.data.msg);
        });
    },
    // 市级获取运营中心
    getservice(cityvalue) {
      this.isareashow = false
      getService(cityvalue).then((res) => {
        // console.log(res);
        this.centre = res.data.data;
      });
    },

    // 重名检测
    duplication_name() {
      dupliCation(this.formationdata.travel_agency_name)
        .then(() => {
          // console.log(res);
        })
        .catch((error) => {
          // console.log(error);
          this.$message.error(error.data.msg);
        });
    },
  },
}